<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <fruit-list :list='list'>
            <template slot-scope='slotProps'>
                <!-- slotProps也是自定义的 -->
                <strong v-if="slotProps.info.id==2">{{slotProps.info.name}}</strong>
                <strong v-else>{{slotProps.info.name}}</strong>
            </template>
        </fruit-list>
    </div>
    <script src="../js/vue.min.js"></script>
    <script>
        // 作用域插槽是在父组件中对子组件进行加工和处理
        // info是自定义的
        Vue.component('fruit-list', {
            props: ['list'],
            template: `
            <div>
                  <li :key='item.id' v-for='item in list'>
                    <slot :info='item'>{{item.name}}</slot>    
                </li>
            </div>
            `
        })
        let vm = new Vue({
            el: '#app',
            data: {
                list: [{
                    id: 1,
                    name: '邵鹏松'
                }, {
                    id: 2,
                    name: '物业零'

                }, {
                    id: 3,
                    name: '吴国强'
                }]
            }
        })
    </script>
</body>

</html>